﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using WL.Dal;
using WL.Model;

namespace WL
{
    public partial class FrmTableAdd : Form
    {
        private int id = -1;

        public FrmTableAdd()
        {
            InitializeComponent();
        }

        public FrmTableAdd(int id)
        {
            InitializeComponent();
            this.id = id;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Table t = new Table();
            t.id = Convert.ToInt32(tbId.Text);
            t.name = tbName.Text;
            t.ignore = Convert.ToInt32(tbIgnore.Text);
            t.sheetname = tbSheet.Text;

            if (Bll.TableService.addOrUpdateTable(t))
            {
                MessageBox.Show("操作成功");
            }
           
        }

        private void FrmTableAdd_Load(object sender, EventArgs e)
        {
            if (this.id > 0)
            {
                Table t = Bll.TableService.getTableById(this.id);
                tbId.Text = t.id+"";
                tbIgnore.Text = t.ignore + "";
                tbName.Text = t.name;
                tbSheet.Text = t.sheetname;
            }
        }
    }
}
